public class ConverterFactory {
    private final List<Converter> converters = new ArrayList<>();
    
    public void registerConverter(Converter converter) {
        if (converter == null) {
            throw new InvalidConfigurationException("转换器不能为空");
        }
        converters.add(converter);
    }
    
    public Converter getConverter(FileFormat sourceFormat, FileFormat targetFormat) {
        return converters.stream()
                .filter(converter -> converter.support(sourceFormat, targetFormat))
                .findFirst()
                .orElseThrow(() -> new UnsupportedFormatException(sourceFormat, targetFormat));
    }
} 